<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=0;  
$PurviewLevel_Others="yingxiao_vpp_link";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body> 
<?php
if($actions=="up")
{
	$db->excu("UPDATE mx_vpp_link SET `ifhide`='$ifhide' WHERE id='$id' ");
	jump2("修改成功","$FROMURL",0);
}
elseif($actions=="yz")
{
	$db->excu("UPDATE mx_vpp_link SET `yz`='$ifyz' WHERE id='$id' ");
	jump2("修改成功","$FROMURL",0);
}
elseif($actions=="del"){
//删除友情链接
	if(!$iddb&&!$id){
		$fun->popmassage("请选择一篇文章","","popback");
		exit();
	}
	elseif(is_array($iddb))
	{
		foreach($iddb AS $key=>$value){
			$db->excu("DELETE FROM mx_vpp_link WHERE id='$key' ");
		}
	}elseif($id){
		$db->excu("DELETE FROM mx_vpp_link WHERE id='$id' ");
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
}
elseif($actions=="list")
{
//更新选中信息排列顺序
	foreach( $listdb AS $key=>$value){
		$db->excu("UPDATE mx_vpp_link SET `list`='$value' WHERE id='$key' ");
	}
	jump2("修改成功","$FROMURL",1);
}
elseif($actions=="saveadd")
{
//  if($classid==""){
//		$fun->popmassage("请选择系统分类","","popback");
//		exit();
//  }
  if($postdb[name]=="" || empty($postdb[name])){
		$fun->popmassage("请填写网站名称","","popback");
		exit();
  }
  if($postdb[url]=="" || empty($postdb[url])){
		$fun->popmassage("请填写网站地址","","popback");
		exit();
  }
  $classid=intval($classid);

    if ($postdb[orderid]==""){$postdb[orderid]=666;}
	$file=$_FILES['picurl'];
	if (!empty($file["name"])){
	$iname = date("YmdHis");
	$picType = explode(".",$_FILES["picurl"]["name"]);
		$picType = $picType[1];		
		$picPath = "../{$webdb[updir]}/friendlink/".date("Ym")."/".$iname.".".$picType;
		$img="friendlink/".date("Ym")."/".$iname.".".$picType;
		movefile("","","../{$webdb[updir]}/friendlink/".date("Ym")."/");
		if(move_uploaded_file($_FILES['picurl']['tmp_name'], $picPath))
		{
			chmod($picPath,0755);
		}else{
		/*print_r($_FILES["file"]);*/
		}	
	}

	$db->excu("INSERT INTO `mx_vpp_link` (classid,fid,`name` , `url` , `logo` , `descrip` ,ifhide,yz,list,adddate,addid) VALUES ('$classid','$type','$postdb[name]','$postdb[url]','$img','$postdb[descrip]','$postdb[ifhide]','$postdb[yz]','$postdb[orderid]','".date("Y-m-d H:i:s")."','".$_SESSION['mxadmin']['userid']."')");
	jump2("添加成功","yx_vpp_link.php");
	exit();
}
elseif ($actions=="savemodi"){
    if($id=="" || empty($id)){
		$fun->popmassage("请选择要修改的友情链接","","popback");
		exit();
  }
//  if($classid==""){
//		$fun->popmassage("请选择系统分类","","popback");
//		exit();
//  }
  $classid=intval($classid);

  if($postdb[name]=="" || empty($postdb[name])){
		$fun->popmassage("请填写网站名称","","popback");
		exit();
  }
  if($postdb[url]=="" || empty($postdb[url])){
		$fun->popmassage("请填写网站地址","","popback");
		exit();
  }
	  
	$file=$_FILES['picurl'];
	if (!empty($file["name"])){
	$iname = date("YmdHis");
	$picType = explode(".",$_FILES["picurl"]["name"]);
		$picType = $picType[1];		
		$picPath = "../{$webdb[updir]}/friendlink/".date("Ym")."/".$iname.".".$picType;
		$img="friendlink/".date("Ym")."/".$iname.".".$picType;
		movefile("","","../{$webdb[updir]}/friendlink/".date("Ym")."/");
		if(move_uploaded_file($_FILES['picurl']['tmp_name'], $picPath))
		{
			chmod($picPath,0755);
		}else{
		/*print_r($_FILES["file"]);*/
		}	
	}
	else{
		$img=$postdb[oldlogo];
	}

	$db->excu("UPDATE mx_vpp_link SET classid='$classid',fid='$type',name='$postdb[name]',url='$postdb[url]',logo='$img',descrip='$postdb[descrip]',`ifhide`='$postdb[ifhide]',`yz`='$postdb[yz]',`list`='$postdb[orderid]',modidate='".date("Y-m-d H:i:s")."',modiid='".$_SESSION['mxadmin']['userid']."' WHERE id='$id' ");
	if ($postdb[oldlogo]!=$img){
		@unlink("../$webdb[updir]/$postdb[oldlogo]");
	}
	if (trim($gotourl)==""){
	$gotourl=$FROMURL;
	}else{$gotourl=url_code($gotourl);}
	jump2("修改成功","$gotourl",1);
	exit();
}

require("../mx_head.php");?>
<div class="right">
<div class="gk">
			<div class="ti2 fl">友情链接管理</div>
			<ul class="fr">
				<li><span class="c1"><?php $znum=$db->listcount("mx_vpp_link","");echo $znum;?></span><span>总条数</span></li>
				<li class="line"></li>
				<li><span class="c2"><?php $znum=$db->listcount("mx_vpp_link"," and yz='1'");echo $znum;?></span><span>已审核</span></li>
				<li class="line"></li>
				<li><span class="c3"><?php $znum=$db->listcount("mx_vpp_link"," and yz='0'");echo $znum;?></span><span>未审核</span></li>
			</ul>
			<div class="clear"></div>
</div>
<div class="height15"></div>

<?php
if ($actions=="add"){?>
<script language="javascript">

function check(){
  if (document.form1.classid.value==""){
    alert('请选择系统分类！');
	document.form1.classid.focus();
	return false;
  }
  if (document.getElementById("linkname").value==""){
    alert('链接名称不能为空！');
	document.getElementById("linkname").focus();
	return false;
  }
  if (document.getElementById("linkurl").value==""){
    alert('链接地址不能为空！');
	document.getElementById("linkurl").focus();
	return false;
  }
  
}
</script>
<div class="xm2">
<h1 class="fl">添加友情链接</h1>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="yx_vpp_link.php?actions=saveadd" onSubmit="return  check();" enctype="multipart/form-data">
     <tr class="list"> 
      <td width='20%'> 
        <div align="left">系统分类：</div>      </td>
      <td colspan="2">
      <select name="classid" id="classid">
      <option value=''>请选择..</option>
		  <?php
		  $sql="select * from mx_vpp_link_type where classid='0' order by orderid, id";
		  $rlt=$db->excu($sql);
		  while($row=@mysql_fetch_object($rlt))
		  {
		  ?>
          <option value="<?php echo $row->id?>"><?php echo $row->type_name?></option>
		  <?php
		  }
		  ?>
      </select>
	  </td>
    </tr>
    <tr class="list"> 
      <td width='20%'> 
        <div align="left">链接名称：</div>      </td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[name]' id="linkname" value='<?php echo $rsdb[name]?>'>      </td>
    </tr>
    <tr class="list"> 
      <td width='19%'> 
        <div align="left">网址：</div>      </td>
      <td colspan="2"><input class=mmcinb type='text' name='postdb[url]' id="linkurl" value='<?php echo $rsdb[url]?>' size='50'></td>
    </tr>
    <tr class="list"> 
      <td width='19%'> 
        <div align="left">LOGO图片：(可为空)</div>      </td>
      <td colspan="2"><input name="picurl" type="file" /></td>
    </tr>
    <tr class="list"> 
      <td width='19%'> 
        <div align="left">描述介绍(可不填)：</div>      </td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[descrip]' value='<?php echo $rsdb[descrip]?>' size='60'>      </td>
    </tr>
    <tr class="list"> 
      <td width='20%'> 
        <div align="left">链接排序：</div>      </td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[orderid]' value='666'>      </td>
    </tr>
    <tr class="list"> 
      <td width='19%'> 
        <div align="left">是否在首页显示:</div>      </td>
      <td colspan="2"> 
        <input type="radio" name="postdb[ifhide]" value="1" checked="checked" class="input_check">
        显示 
        <input type="radio" name="postdb[ifhide]" value="0" class="input_check">
        不显示 </td>
    </tr>
    <tr class="list"> 
      <td width='19%'>验证与否</td>
      <td colspan="2"> 
        <input type="radio" name="postdb[yz]" value="1" checked="checked" class="input_check">
        已验证 
        <input type="radio" name="postdb[yz]" value="0" class="input_check">
        未验证</td>
    </tr>
    <tr class="list"> 
      <td width='19%'> 
        <div align='right'></div>      </td>
      <td colspan="2"> 
        <input class=mmcinb type='submit' name='Submit' value='提交数据'>      </td>
    </tr>
  </form>
</table>
<div class="height10"></div>
</div>
<?php 
}
elseif ($actions=="modi"){
//修改友情链接
  $query="SELECT * FROM mx_vpp_link where id='$id' limit 1";
  $result=$db->excu($query);
  if ($db->num_rows($result)<=0){
	$fun->popmassage("请选择要修改的友情链接","","popback");
	exit();
  }

  $rsdb=$db->fetch_array($result);
	$rsdb[ifhide]=intval($rsdb[ifhide]);
	$ifhide[$rsdb[ifhide]]=" checked ";
	$rsdb[yz]=intval($rsdb[yz]);
	$yz[$rsdb[yz]]=" checked ";
	if ($gotourl==""){$gotourl=url_encode($_SERVER['HTTP_REFERER']);}

?>
<script language="javascript">
function check(){
  if (document.form1.postdb[name].value==""){
    alert('链接名称不能为空！');
	document.form1.postdb[name].focus();
	return false;
  }
  if (document.form1.postdb[url].value==""){
    alert('链接地址不能为空！');
	document.form1.postdb[url].focus();
	return false;
  }
  
}
</script>
<div class="xm2">
<h1 class="fl">添加友情链接</h1>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="yx_vpp_link.php" onSubmit="return  check();" enctype="multipart/form-data">
  <tr class="list"> 
      <td width='20%'> 
        <div align="left">系统分类：</div>      </td>
      <td colspan="2">
      <select name="classid" id="classid" > 
      <option value=''>请选择..</option>
		  <?php
		  $sql="select * from mx_vpp_link_type where classid='0' order by orderid, id";
		  $rlt=$db->excu($sql);
		  while($row=@mysql_fetch_object($rlt))
		  {
		  ?>
          <option value="<?php echo $row->id?>" <?php if ($rsdb["classid"]==$row->id){echo "selected";} ?>><?php echo $row->type_name?></option>
		  <?php
		  }
		  ?>
      </select>
	  </td>
    </tr>
    <tr class="list"> 
      <td width='20%'>链接名称：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[name]' id="linkname" value='<?php echo $rsdb[name]?>'>      </td>
    </tr>
    <tr class="list"> 
      <td>网址：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[url]' id="linkurl" value='<?php echo $rsdb[url]?>' size='50'>      </td>
    </tr>
    <tr class="list"> 
      <td>LOGO图片：</td>
      <td colspan="2"><input name="picurl" type="file" /><input type="hidden" name="postdb[oldlogo]" value="<?php echo $rsdb[logo]?>">&nbsp;不修改时请留空</td>
    </tr>
<?php if ($rsdb[logo]!=""){?>
<tr class="list">
  <td></td>
  <td><img src="<?php echo get_photourl($rsdb[logo]) ?>" ></td>
</tr>
<?php }?>
    <tr class="list"> 
      <td>描述介绍(可不填)：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[descrip]' value='<?php echo $rsdb[descrip]?>' size='60'>      </td>
    </tr>
    <tr class="list"> 
      <td>链接排序：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[orderid]' value='<?php echo $rsdb["list"]?>'>      </td>
    </tr>
    <tr class="list"> 
      <td>是否在首页显示：</td>
      <td colspan="2"> 
        <input type="radio" name="postdb[ifhide]" value="1" class="input_check" <?php echo $ifhide[1]?>>
        显示 
        <input type="radio" name="postdb[ifhide]" value="0" class="input_check" <?php echo $ifhide[0]?>>
        不显示 </td>
    </tr>
    <tr class="list"> 
      <td>验证与否</td>
      <td colspan="2"> 
        <input type="radio" name="postdb[yz]" value="1" class="input_check" <?php echo $yz[1]?>>
        已验证 
        <input type="radio" name="postdb[yz]" value="0" class="input_check" <?php echo $yz[0]?>>
        未验证</td>
    </tr>
    <tr class="list"> 
      <td></td>
      <td colspan="2"> 
        <input class="button" type='submit' name='Submit' value='提交数据'>
		<input type="hidden" name="id" value="<?php echo $rsdb[id] ?>">
		<input type="hidden" name="gotourl" value="<?php echo $gotourl?>">
		<input type="hidden" name="actions" value="savemodi">      </td>
    </tr>
  </form>
</table>
<div class="height10"></div>
</div>
<?php 
}

else{  
  $str="";
  $s="";
  if(empty($pageindex)){
      $pageindex=1;
  }
  $pagesize=15;
  $classid=intval($classid);
  if ($classid>0){
    $str.=" and classid='$classid' ";
	$s.="classid=$classid&";
  }
  if ($yz!=""){
  	$yz=intval($yz);
	$str.=" and yz='$yz' ";
	$s.="yz=$yz&";
  }
  
  $table=" mx_vpp_link ";
  $order=" order by list asc, id desc";
  $column=" * ";
  $biaoid="id";
  $c=$db->listcount($table,$str);
  
  $list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);
?>
<div class="xm2">
<h1 class="fl">友情链接管理</h1>
</div>
<div class="xm2_b" style="border-bottom:0px;">
<div class="t">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<div class="an1"><a href="yx_vpp_link.php">所有信息</a></div>
	<div class="an2"><a href="yx_vpp_link.php?actions=add">添加链接</a></div>
	<div class="an2"><a href="yx_vpp_link.php?yz=1">已审核</a></div>
	<div class="an2"><a href="yx_vpp_link.php?yz=0">未审核</a></div>
	<?PHP
	$sqlf="select * from mx_vpp_link_type where classid='0' order by orderid, id";
	$resultf=$db->excu($sqlf);
	$i=0;
	if ($db->num_rows($resultf)>0){
	while($rstf=$db->fetch_array($resultf)){
	?>
	<div class="an2"><a href="yx_vpp_link.php?classid=<?php echo $rstf['id'];?>"><?php echo $rstf['type_name'];?></a></div>
	<?php
	}
	}
	?>
	</td>
	</tr>
	</table>
</div>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="yx_vpp_link.php">
    <tr> 
      <th width="5%" align="center">ID </th>
      <th width="20%" align="center">名称</th>
      <th width="9%" align="center">首页显示</th>
      <th width="8%" align="center">排序</th>
      <th width="12%" align="center">LOGO</th>
      <th width="12%" align="center">审核与否</th>
      <th width="13%" align="center">操作</th>
    </tr>
<?php
  if (!is_array($list)){
  echo "<tr class=\"list1\" onMouseOver=\"this.className='list2'\" onmouseout=\"this.className='list1'\"><td colspan=5><center>暂无信息</center></td></tr>";
  }
  else{
  for($i=0;$i<count($list);$i++){
		$list[$i][ifshow]=$list[$i][ifhide]?"<A HREF='?actions=up&ifhide=0&id=".$list[$i][id]."' style='color:red;' title='隐藏该内容'>显示</A>":"<A HREF='?actions=up&ifhide=1&id=".$list[$i][id]."' style='color:blue;' title='显示该内容'>隐藏</A>";

		$list[$i][yz]=$list[$i][yz]?"<A HREF='?actions=yz&ifyz=0&id=".$list[$i][id]."' style='color:red;' title='取消审核'>已审核</A>":"<A HREF='?actions=yz&ifyz=1&id=".$list[$i][id]."' style='color:blue;' title='审核通过'>未审核</A>";
?>
    <tr class="list"> 
      <td width='5%' align="center"><input type="checkbox" name="iddb[<?php echo $list[$i][id]?>]" value="<?php echo $list[$i][id]?>" class="input_check"></td>
      <td width="17%">
        <a href="<?php echo $list[$i][url]?>" target="_blank"><?php echo $list[$i][name]?></a> </td>
      <td width="9%" align="center"><?php echo $list[$i][ifshow]?></td>
      <td width="8%" align="center"> 
        <input type="text" name="listdb[<?php echo $list[$i][id] ?>]" size="7" value="<?php echo $list[$i]['list']?>">
      </td>
      <td width="18%" align="center"><?php if (trim($list[$i][logo])==""){?><a href="<?php echo $list[$i][url]?>" target="_blank"><img src="<?php echo get_photourl($list[$i][logo])?>" width="100" /></a><?php }?></td>
      <td width="12%" align="center"><?php echo $list[$i][yz]?></td>
      <td width="13%" align="center"><a href="yx_vpp_link.php?actions=modi&id=<?php echo $list[$i][id]?>">修改</a>&nbsp;&nbsp;<a href="yx_vpp_link.php?actions=del&id=<?php echo $list[$i][id]?>" onClick="return confirm('确定要删除此信息吗?')">删除</a></td>
    </tr>
<?php
}
?>
<?php }?>
  <input type="hidden" name="actions" id="actions" value="" />
  </form>
</table>
<?php if ($c>0){?>
			<div class="height10"></div>
			<div class="do_div">
				<div class="l"><a href="javascript:CheckAll(document.form1,'all')">全选</a>&nbsp;<a href="javascript:CheckAll(document.form1,'')">反选</a><input type="hidden" name="jobs" value="0"></div>
				<div class="l2">
				选择操作：
				<a href="javascript:if (confirm('确定要删除选中的信息吗?')){ document.form1.actions.value='del';document.form1.submit();}">删除选中信息</a>
				<a href="javascript:document.form1.actions.value='list';document.form1.submit();">提交处理排序</a>
				</div>
			</div>
<?php }?>
<?php
  if ($c>$pagesize){
?>
			<div class="clear"></div>
			<div class="pagination">
			<?PHP
			echo $db->ThePage_mxsoft($s,$pageindex,$c,$pagesize)
			?>
			</div>
			<div class="clear"></div>
			<div class="height10"></div>
<?php
	}
?>

<div class="height10"></div>
</div>
<script type="text/javascript" src="/mxsoft/js/jquerys-1.5.1.js"></script>
<script language="javascript">
$(document).ready(function(){  
	$(".table_southidc tr").mouseover(function(){   
	$(this).addClass("list2");}).mouseout(function(){   
	$(this).removeClass("list2");}) //移除该行的class   
	$(".table_southidc tr:even").addClass("list1");   
});   
</script> 
<?php
}
?>
<div class="clear"></div>
<div class="height10"></div>
</div>
<?php require("../mx_foot.php");?>
<div class="clear"></div>
<div class="height10"></div>
</body>
</html>
